package com.design.classroommanagement

import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import com.design.classroommanagement.activity.LoginActivity
import com.design.classroommanagement.activity.MainActivity
import com.design.classroommanagement.activity.RegisterActivity
import com.design.classroommanagement.manager.UserAccountManager.isLogin
import com.design.classroommanagement.util.DBUtils.Companion.connect
import com.laughing.lib.utils.startActivity

class LaunchActivity : AppCompatActivity() {
    private var btnLogin: Button? = null
    private var btnRegister: Button? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        if (isLogin()) {
            startActivity<MainActivity>()
            finish()
        }
        setContentView(R.layout.activity_launch)
        connect
        btnLogin = findViewById(R.id.btn_login)
        btnLogin?.setOnClickListener(View.OnClickListener { //为了跳转到登录界面，
            val intent = Intent(this@LaunchActivity, LoginActivity::class.java)
            startActivity(intent)
            finish()
        })
        btnRegister = findViewById(R.id.btn_register)
        btnRegister?.setOnClickListener(View.OnClickListener { //为了跳转到注册界面，
            val intent = Intent(this@LaunchActivity, RegisterActivity::class.java)
            startActivity(intent)
            finish()
        })
    }
}